import {
    create
} from 'zustand';
import { getDetail } from '@/api/detail'

const useDetailStore = create((set) => ({
    detail: {
        title: '',
        desc: '',
        images: [
            {
                alt: '',
                url: 'https://cn.bing.com/images/search?view=detailV2&ccid=mH9YLFEL&id=457EC80FCD5EE9AB67B2B3E8F5624312D6F6400B&thid=OIP.mH9YLFEL5YdVxJM82mjVJQHaEo&mediaurl=https%3a%2f%2fts1.tc.mm.bing.net%2fth%2fid%2fR-C.987f582c510be58755c4933cda68d525%3frik%3dC0D21hJDYvXosw%26riu%3dhttp%253a%252f%252fimg.pconline.com.cn%252fimages%252fupload%252fupc%252ftx%252fwallpaper%252f1305%252f16%252fc4%252f20990657_1368686545122.jpg%26ehk%3dnetN2qzcCVS4ALUQfDOwxAwFcy41oxC%252b0xTFvOYy5ds%253d%26risl%3d%26pid%3dImgRaw%26r%3d0&exph=1600&expw=2560&q=%e5%9b%be%e7%89%87&FORM=IRPRST&ck=64AA5AA7AF596CB282CA07D732152DDF&selectedIndex=0&itb=0&idpp=overlayview&ajaxhist=0&ajaxserp=0'
            }
        ],
        price: ''
    },
    loading: false,
    setDetail: async () => {
        set({loading: true})
        const res = await getDetail();
        set({
            loading: false,
            detail: res.data
        });
    }
}))

export default useDetailStore